package com.berchen.file;

import java.io.File;

public class FileTest {
    public static void main(String[] args) {
        File file=new File(FileTest.class.getClassLoader().getResource("").getPath());
        File[] files = file.listFiles();
        System.out.println("打印所有目录+文件");
        for (File f:files){
            System.out.println(f.getPath());
        }

        System.out.println("只打印目录");
        for (File f:files){
            if(f.isDirectory()) {
                System.out.println(f.getPath());
            }
        }

        System.out.println("通过过滤器来过滤 ");
        File[] files1 = file.listFiles((f) ->f.isDirectory());
        for (File file1 : files1) {
            System.out.println(file1);
        }
    }
}
